<?php

/**
 * @user magein
 * @date 2024/2/4 20:14
 */

namespace magein\sms;

use magein\utils\Result;
use magein\sms\platform\Platform;

/**
 * 发送类
 */
class Send
{

    protected $config = null;

    public function __construct($config = [])
    {
        $this->config = $config;
    }

    /**
     * @param $data
     * @return Platform
     * @throws SmsException
     */
    public function platform($data): Platform
    {
        return Factory::make($this->config, $data);
    }

    /**
     * 发送验证码
     * @param $data
     * @return Result
     * @throws SmsException
     */
    public function code($data): Result
    {
        return $this->platform($data)->code();
    }

    /**
     * 发送短信
     * @param $data
     * @return Result
     * @throws SmsException
     */
    public function message($data): Result
    {
        return $this->platform($data)->send();
    }
}